import requestMeeting from '@/plugins/axios'
import { SendSms, SmsEntity } from './interface'

export const fetchStopMsg = async ({ meetingMoid, mts }: { meetingMoid: string; mts?: string[] }) =>
	requestMeeting({
		url: `/mcc/${meetingMoid}/shortmsg`,
		method: 'delete',
		data: mts || [],
	}).then((res) => res.success)

export const fetchSendMsg = async (data: SendSms, meetingMoid: string) =>
	requestMeeting({
		url: `/mcc/${meetingMoid}/shortmsg`,
		method: 'post',
		data: data,
	}).then((res) => res.success)

export const fetchSaveMsg = async (data: { id: string; msg: string }) =>
	requestMeeting({
		url: '/mcc/usual_shortmsg',
		method: 'post',
		data: data,
	}).then((res) => res)

export const fetchClearMsg = async (id?: string) =>
	requestMeeting({
		url: id ? `/mcc/usual_shortmsg?id=${id}` : '/mcc/usual_shortmsg',
		method: 'delete',
	}).then((res) => res.success)

export const fetchGetAllMsg = async (meetingMoid: string) =>
	requestMeeting<SmsEntity[]>({
		url: `/mcc/${meetingMoid}/usual_shortmsg`,
		method: 'get',
		params: {},
	}).then((res) => (res.success ? res.data : undefined))
